package com.example.myapplication.volunteerservice;

import android.os.Bundle;

import androidx.fragment.app.Fragment;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.example.myapplication.R;
import com.google.android.material.tabs.TabLayout;

import java.util.ArrayList;


public class MyFragment extends Fragment {

    private View view;
    private TabLayout mytab;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        view = inflater.inflate(R.layout.fragment_my, container, false);
        initview();
        //页面分 3 个标签页，
        labelpage();
        return view;
    }

    private void labelpage() {
        ArrayList<String> list = new ArrayList<>();
        list.add("已报名");
        list.add("已完成");
        list.add("已取消");


        for (int i = 0; i < list.size(); i++) {
            TabLayout.Tab tab = mytab.newTab();
            tab.setText(list.get(i));
            mytab.addTab(tab);
        }

    }

    private void initview() {
        mytab = view.findViewById(R.id.tab);
    }
}